#!/usr/bin/env python

import os,sys
import leveldb

class DB:
	def __init__(self):
		self.db = leveldb.LevelDB('./163db')

	def put(self,key,value):
		self.db.Put(key,value)

	def get(self,key):
		return self.db.Get(key)

def data_write(fn):
	db = DB()
	f = open(fn,"r")
	while 1:
		line = f.readline()
		if not line:
			break
		line = line.strip()
		kv = line.split('----')
		db.put(kv[0],kv[1])
	print 'finished'

def key_search(key):
	db = DB()
	try:
		value = db.get(key)
		print value
	except Exception,e:
		print "not found"

if __name__ == '__main__':
	keywords = ""
	if len(sys.argv) > 1:
		keywords = sys.argv[1]
	else:
		keywords = raw_input("input keywords:")

	print keywords 
	key_search(keywords)
